"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Point_1 = require("./core/Point");
// 定义地形比例
const terrainRatios = {
    [Point_1.Terrain.KONG]: 0.55,
    [Point_1.Terrain.SHAN]: 0.15,
    [Point_1.Terrain.SHUI]: 0.13,
    [Point_1.Terrain.LIN]: 0.1,
    [Point_1.Terrain.SHA]: 0.05,
    [Point_1.Terrain.JING]: 0.02 // 水晶单独处理
};
class MapCreator {
    constructor() {
        // 地图半径
        this.radius = 15;
        /***************************** 直接读取本地的 **************************************/
        this.arr_points = require("../../地图文件/map.json");
    }
    // 生成地图数据
    generateMap(gameMgr) {
        const list = new Array();
        for (let y = -this.radius; y <= this.radius; y++) {
            let is_ban = false; // 是否+0.5
            if (y % 2 == 0) {
                is_ban = true;
            }
            for (let x = -this.radius; x <= this.radius; x++) {
                let xx = x + (is_ban ? 0 : 0.5);
                if (Math.pow(xx, 2) + Math.pow(y, 2) > Math.pow(this.radius, 2)) {
                    continue;
                }
                let point = new Point_1.Point(gameMgr, xx, y, this.randomTerrain());
                list.push(point);
            }
        }
        return list;
    }
    /** 随机地形 */
    randomTerrain() {
        const randNum = Math.random();
        let cumulativeRatio = 0;
        let terrain = Point_1.Terrain.KONG;
        for (const [t, ratio] of Object.entries(terrainRatios)) {
            cumulativeRatio += ratio;
            if (randNum < cumulativeRatio) {
                terrain = parseInt(t);
                break;
            }
        }
        return terrain.valueOf();
    }
    getArrPoints(gameMgr) {
        let arr_points = new Array();
        for (var p of this.arr_points) {
            arr_points.push(new Point_1.Point(gameMgr, p.x, p.y, p.terrain));
        }
        return arr_points;
    }
}
exports.default = new MapCreator();
